package org.kotboot.config;

import org.kotboot.intercepter.AuthIntercepter;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * jisong.sun 2017/9/15 16:03
 */

@SpringBootConfiguration
@EnableWebMvc
public class ConfigInterceptor implements WebMvcConfigurer {

    @Bean
    public AuthIntercepter authIntercepter(){
        return new AuthIntercepter();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authIntercepter())
                .addPathPatterns("/**");
    }
}
